package main

import (
	bc "application/blockchain"
	"encoding/json"
	"fmt"
)

func main() {
	var args [][]byte
	err := bc.InitSDK()
	if err != nil {
		fmt.Printf("Init sdk error: %v", err)
	}
	args = append(args, []byte("asset1"))
	resp, err := bc.ChannelQuery(bc.Sdk, "ReadAsset", args)
	if err != nil {
		fmt.Printf("Quert fcn ReadAsset err: %v", err)
	}
	fmt.Printf("resp.Payload = %v\n", resp.Payload)
	fmt.Printf("resp.Payload json = %v\n", string(resp.Payload))
	var data map[string]interface{}
	// var data interface{}
	// err = json.Unmarshal(bytes.NewBuffer(resp.Payload).Bytes(), &data)
	err = json.Unmarshal(resp.Payload, &data)
	if err != nil {
		fmt.Printf("Unmarshal resp data err: %v\n", err)
	}
	fmt.Printf("data = %v\n", data)
}
